﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using S4Store.Domain.NetMarketingKpi;
using LX.Web.Excel;

namespace S4Store.Domain.NetMarketingKpiReport
{
    public class NetMarketingMediaGroupReport : NetMarketingStoreReport
    {
        [Export("合计标题")]
        public override string HjTitle
        {
            get { return Type.GetDescription()+"小计"; }
        }

        public NetMarketingMediaGroupReport(NetMarketingStoreReport storereport,S4Store.Domain.NetMarketingKpi.NetMarketingMedia.MediaType type) :base()
        {
            StoreReport = storereport;
            Type = type;
            this.Year = StoreReport.Year;
            this.Month = StoreReport.Month;
            this.Day = StoreReport.Day;
            this.NetMarketingStandard = StoreReport.NetMarketingStandard;
            this.NetMarketingKpiMonthConfig = StoreReport.NetMarketingKpiMonthConfig;
            
        }

        public NetMarketingStoreReport StoreReport { get; set; }
        public S4Store.Domain.NetMarketingKpi.NetMarketingMedia.MediaType Type { get; set; }

        private List<NetMarketingMediaReport> _mediaReports = new List<NetMarketingMediaReport>();
        public override List<NetMarketingMediaReport> MediaReports
        {
            get
            {
                return StoreReport.MediaReports.Where(t => t.Media.Type == Type).ToList();
            }
            set
            {
                _mediaReports = value;
                if (StoreReport != null)
                {
                    StoreReport.MediaReports = value;
                }
            }
        }

        /// <summary>
        /// 资金投入比
        /// </summary>
        [Export("资金投入比", Format = "{0}%")]
        public override decimal ZJTRB
        {
            get
            {
                if (StoreReport.YDFY == 0) return 0;
                return YDFY * 100 / StoreReport.YDFY;
            }
        }
    }
}
